﻿using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;

namespace ServerTest
{
    /// <summary>
    /// Description résumée de Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class CoolService : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            BreakOnceUponTwo();
            return "Hello World " + HttpContext.Current.Request.Url;
        }

        [WebMethod]
        public int Sum(int i, int j)
        {
            BreakOnceUponTwo();
            return i + j;
        }

        [WebMethod]
        public string[] Split(string sentence, string separator)
        {
            BreakOnceUponTwo();
            return sentence.Split(new string[] { separator }, StringSplitOptions.RemoveEmptyEntries);
        }

        private void BreakOnceUponTwo()
        {
            double successProbability = 0.4;
            if (new Random().Next() > successProbability * int.MaxValue) throw new ApplicationException("You lost");
        }
    }
}
